// Package middleware adds request-scoped values such as role into context.
package middleware

import "context"

type ctxKey string

const roleKey ctxKey = "role"

func WithRole(ctx context.Context, role string) context.Context {
	return context.WithValue(ctx, roleKey, role)
}
func RoleFromContext(ctx context.Context) string {
	v := ctx.Value(roleKey)
	if v == nil {
		return ""
	}
	s, _ := v.(string)
	return s
}
